css: Support overline
authorMatthias Clasen <mclasen@redhat.com>
Tue, 26 Jan 2021 05:04:04 +0000 (00:04 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 26 Jan 2021 05:04:04 +0000 (00:04 -0500)
We can support text-decoration-line: overline,
since pango supports it now.

docs/reference/gtk/css-properties.md
gtk/gtkcssenumvalue.c
gtk/gtkcssstyle.c
gtk/gtkcsstypesprivate.h

index e50f577650658d06f6106a7d6d37998bf34ed1ca..96fb3be0e0a777bccfac4ed48537858fa2477545 100644 (file)
@@ -151,7 +151,7 @@ done with
 |caret-color|[CSS Basic User Interface Level 3](https://www.w3.org/TR/css3-ui/#caret-color) | CSS allows an auto value |
 |-gtk-secondary-caret-color|[Color](https://www.w3.org/TR/css-color-3/#valuea-def-color) | used for the secondary caret in bidirectional text |
 |letter-spacing| [CSS Text Level 3](https://www.w3.org/TR/css3-text/#letter-spacing) | |
-|text-decoration-line| [CSS Text Decoration Level 3](https://www.w3.org/TR/css-text-decor-3/#text-decoration-line-property) | CSS allows overline |
+|text-decoration-line| [CSS Text Decoration Level 3](https://www.w3.org/TR/css-text-decor-3/#text-decoration-line-property) | |
 |text-decoration-color| [CSS Text Decoration Level 3](https://www.w3.org/TR/css-text-decor-3/#text-decoration-color-property) | |
 |text-decoration-style| [CSS Text Decoration Level 3](https://www.w3.org/TR/css-text-decor-3/#text-decoration-style-property) | CSS allows dashed and dotted |
 |text-shadow| [CSS Text Decoration Level 3](https://www.w3.org/TR/css-text-decor-3/#text-shadow-property) | |
index 9bd29e3742ff7220583a8a7a79b1043906d37281..6a9b4bfec7cc74566480d41695530194070ef070 100644 (file)
@@ -561,6 +561,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_TEXT_DECORATION_LINE = {
 static GtkCssValue text_decoration_line_values[] = {
   { &GTK_CSS_VALUE_TEXT_DECORATION_LINE, 1, TRUE, GTK_CSS_TEXT_DECORATION_LINE_NONE, "none" },
   { &GTK_CSS_VALUE_TEXT_DECORATION_LINE, 1, TRUE, GTK_CSS_TEXT_DECORATION_LINE_UNDERLINE, "underline" },
+  { &GTK_CSS_VALUE_TEXT_DECORATION_LINE, 1, TRUE, GTK_CSS_TEXT_DECORATION_LINE_OVERLINE, "overline" },
   { &GTK_CSS_VALUE_TEXT_DECORATION_LINE, 1, TRUE, GTK_CSS_TEXT_DECORATION_LINE_LINE_THROUGH, "line-through" },
 };
 
index 5d5fc2b44f52ba5e8a8a6eefe732a6ef534eb3ea..ee6f9c44c56468b3cadb2d37f1886a484e915a3c 100644 (file)
@@ -397,6 +397,12 @@ get_pango_underline_from_style (GtkTextDecorationStyle style)
   g_return_val_if_reached (PANGO_UNDERLINE_SINGLE);
 }
 
+static PangoOverline
+get_pango_overline_from_style (GtkTextDecorationStyle style)
+{
+  return PANGO_OVERLINE_SINGLE;
+}
+
 static PangoAttrList *
 add_pango_attr (PangoAttrList  *attrs,
                 PangoAttribute *attr)
@@ -454,6 +460,13 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
                                                                        decoration_color->green * 65535. + 0.5,
                                                                        decoration_color->blue * 65535. + 0.5));
       break;
+    case GTK_CSS_TEXT_DECORATION_LINE_OVERLINE:
+      attrs = add_pango_attr (attrs, pango_attr_overline_new (get_pango_overline_from_style (decoration_style)));
+      if (!gdk_rgba_equal (color, decoration_color))
+        attrs = add_pango_attr (attrs, pango_attr_overline_color_new (decoration_color->red * 65535. + 0.5,
+                                                                      decoration_color->green * 65535. + 0.5,
+                                                                      decoration_color->blue * 65535. + 0.5));
+      break;
     case GTK_CSS_TEXT_DECORATION_LINE_LINE_THROUGH:
       attrs = add_pango_attr (attrs, pango_attr_strikethrough_new (TRUE));
       if (!gdk_rgba_equal (color, decoration_color))
index fe30beaae10a13dcabd280ece35ab9347b4265c4..efb54a5561d6c937e3a733246e20d31a13ca0451 100644 (file)
@@ -327,6 +327,7 @@ typedef enum /*< skip >*/ {
 typedef enum /*< skip >*/ {
   GTK_CSS_TEXT_DECORATION_LINE_NONE,
   GTK_CSS_TEXT_DECORATION_LINE_UNDERLINE,
+  GTK_CSS_TEXT_DECORATION_LINE_OVERLINE,
   GTK_CSS_TEXT_DECORATION_LINE_LINE_THROUGH
 } GtkTextDecorationLine;